using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using CRC.GestionSalones.Presentacion;

namespace CRC
{
    public partial class usrGestSalones : UserControl
    {
        DataAccess bd = new DataAccess();

        public usrGestSalones()
        {
            InitializeComponent();
        }

        private void cntBuscar1_CargarSalon(int ID)
        {

            usrSalones1.LoadX = ID;
            usrSalones1.CargarDatos();

            ButtonSelected("btnSalon");
            usrSalones1.Visible = true;   
        }

        private void cntBuscar1_CargarCongregacion(int ID)
        {
                usrCongregaciones1.Load_Id = ID;
                usrCongregaciones1.CongLoad();

                ButtonSelected("btnCong");
                usrCongregaciones1.Visible = true;
        }

        private void usrSalones1_CargarCongregacion(int ID)
        {
            usrCongregaciones1.Load_Id = ID;
            usrCongregaciones1.CongLoad();

            ButtonSelected("btnCong");
            usrCongregaciones1.Visible = true;
        }

        private void usrGestSalones_Load(object sender, EventArgs e)
        {
            pnlMenu.Width = this.Width;
            pnlMain.Width = this.Width;
            
            //btnLstSalones_Click(e, EventArgs.Empty);
            
        }

        private void ButtonSelected(string strName)
        {
            
            for (int i = 0; i <= pnlMenu.Controls.Count-1; i++)
            {                
                if (pnlMenu.Controls[i].Name.ToString() == strName)
                {
                    pnlMenu.Controls[i].BackColor = Color.SandyBrown;
                }
                else
                {
                    pnlMenu.Controls[i].BackColor = Color.LightSteelBlue;
                }
            }
            
            for (int i = 0; i <= pnlMain.Controls.Count - 1; i++)
            {
                pnlMain.Controls[i].Visible = false;
            }
        }
        
        private void btnLstSalones_Click(object sender, EventArgs e)
        {
            UsrListadoSalones usrListadoSalones = new UsrListadoSalones();
            usrListadoSalones.Dock = DockStyle.Fill;
            this.Controls.Add(usrListadoSalones);
            usrListadoSalones.Show();
            usrListadoSalones.BringToFront();

            //ButtonSelected("btnLstSalones");
            //cntBuscar1.Consulta = "Salones";
            //cntBuscar1.Visible = true;            
        }

        private void btnListCong_Click(object sender, EventArgs e)
        {
            ButtonSelected("btnListCong");
            cntBuscar1.Consulta = "Congregaciones";
            cntBuscar1.Visible = true;     
        }

        private void btnSalon_Click(object sender, EventArgs e)
        {
            ButtonSelected("btnSalon");
            usrSalones1.Visible = true;     
        }

        private void btnCong_Click(object sender, EventArgs e)
        {            
            ButtonSelected("btnCong");
            usrCongregaciones1.Visible = true;     
        }

        private void btnHI_Click(object sender, EventArgs e)
        {
            
        }


    }
}
